﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

/// <summary>
/// Summary description for Service_ThongKe
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Service_ThongKe : System.Web.Services.WebService {

    public Service_ThongKe () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

    BieumauDataContext db = new BieumauDataContext();

   
    [WebMethod]
    public DataTable getBieuMau(int nam)
    {
        var p = from t in db.tblBieuMaus
                where t.NamBaoCao == nam && t.TenBieuMau.StartsWith("BM")
                select t;
        DataTable dt = new DataTable();
        dt.TableName = "BieuMau";

        dt.Columns.Add("MaDonVi", typeof(string));
        dt.Columns.Add("NamBaoCao", typeof(string));
        dt.Columns.Add("TenBieuMau", typeof(string));
        dt.Columns.Add("NoiNhan", typeof(string));
        dt.Columns.Add("NgayNop", typeof(string));
        dt.Columns.Add("DaNop", typeof(string));
        dt.Columns.Add("DuLieu", typeof(string));

        foreach (tblBieuMau item in p)
        {
            dt.Rows.Add(item.MaDonVi, item.NamBaoCao, item.TenBieuMau, item.NoiNhan, item.NgayNop, item.DaNop, item.DuLieu);
        }


        return dt;
    }

    [WebMethod]
    public DataTable getPhuLuc(int nam)
    {
        var p = from t in db.tblBieuMaus
                where t.NamBaoCao == nam && t.TenBieuMau.StartsWith("PL")
                select t;
        DataTable dt = new DataTable();
        dt.TableName = "BieuMau";

        dt.Columns.Add("MaDonVi", typeof(string));
        dt.Columns.Add("NamBaoCao", typeof(string));
        dt.Columns.Add("TenBieuMau", typeof(string));
        dt.Columns.Add("NoiNhan", typeof(string));
        dt.Columns.Add("NgayNop", typeof(string));
        dt.Columns.Add("DaNop", typeof(string));
        dt.Columns.Add("DuLieu", typeof(string));

        foreach (tblBieuMau item in p)
        {
            dt.Rows.Add(item.MaDonVi, item.NamBaoCao, item.TenBieuMau, item.NoiNhan, item.NgayNop, item.DaNop, item.DuLieu);
        }


        return dt;
    }
    
}
